<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>冒泡排序</title>
	</head>
	<body>
		<script>
			var arr=[98,31,5,27,2,78];
			console.log("待排序的数组"+arr);
			for (var i = 1; i < arr.length; i++) {
				for (var j = 0; j < arr.length-i; j++) {
					if(arr[j]>arr[j+1]){
						var t=arr[j];
						arr[j]=arr[j+1];
						arr[j+1]=t;
					}
				}
			}
			console.log("排序后的数组"+arr)
		</script>
	</body>
</html>
